package com.twu.bibilioteca;

/**
 * Created by IntelliJ IDEA.
 * User: dixithk
 * Date: 6/20/14
 * Time: 6:33 AM
 * To change this template use File | Settings | File Templates.
 */
public class Movie {
    private String name ;
    private String director;
    private int year;
    private int rating;
    private boolean isCheckOut;


    public Movie(String name , String director , int year ,int rating)
    {
         this.name = name;
        this.director = director;
        this.year=year;
        this.rating = rating;
        this.isCheckOut = false;

    }


    public String getName()
    {
        return name;
    }

    public String getDirector()
    {
        return director;
    }

    public int getYear()
    {
        return year;
    }

    public int getRating()
    {
        return rating;
    }


    public boolean isCheckedOut() {
        return isCheckOut;
    }

    public void markAsCheckedOut() {
         isCheckOut = true;
    }

    public void markAsReturned() {
        isCheckOut = false;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Movie movie = (Movie) o;

        if (isCheckOut != movie.isCheckOut) return false;
        if (rating != movie.rating) return false;
        if (year != movie.year) return false;
        if (director != null ? !director.equals(movie.director) : movie.director != null) return false;
        if (name != null ? !name.equals(movie.name) : movie.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (director != null ? director.hashCode() : 0);
        result = 31 * result + year;
        result = 31 * result + rating;
        result = 31 * result + (isCheckOut ? 1 : 0);
        return result;
    }
}

